<template>
  <div id="scroll-board1">
    <dv-scroll-board :config="config" />
  </div>
</template>

<script>
import FullScreenMonitor from "@/api/FullScreenMonitor";
import {apiResult} from "@/libs/util";
export default {

  name: 'AlarmActualList',
  data () {
    return {
      api: new FullScreenMonitor(),
      timer: null,
      config:{data: [],
        index: true,
        align: ['center'],
        rowNum: 7,
        waitTime: 2000,
        oddRowBGC: 'rgba(0, 44, 81, 0.8)',
        evenRowBGC: 'rgba(10, 29, 50, 0.8)'},
      config0: {
        data: [],
        index: true,
        align: ['center'],
        rowNum: 7,
        waitTime: 2000,
        oddRowBGC: 'rgba(0, 44, 81, 0.8)',
        evenRowBGC: 'rgba(10, 29, 50, 0.8)'
      },
      config1: {
        //header:["时间","部门","报警信息"],
        data: [
          /*['2023-07-05 19:25:00', '长沙分局','路面危害-松散'],
          ['2019-07-02 17:25:00', '广东分局','路面危害-路面油污清理'],
          ['2019-07-03 16:25:00', '长沙分局','交安设施-交通标志牌结构'],
          ['2019-07-04 15:25:00', '长沙分局','路基危害-防尘网'],
          ['2019-07-05 14:25:00', '武汉分局','交安设施-交通标志牌结构'],
          ['2019-07-06 13:25:00', '长沙分局','路面危害-松散'],
          ['2019-07-07 12:25:00', '长沙分局','路基危害-防尘网'],
          ['2019-07-08 11:25:00', '长沙分局','路面危害-路面油污清理'],
          ['2019-07-09 10:25:00', '长沙分局','交安设施-交通标志牌结构'],
          ['2019-07-10 09:25:00', '长沙分局','路基危害-防尘网']*/
        ],
/*        header: ['时间', '报警信息', '数量', '标段'],
        data: [
          ['2019-07-01 19:25:00', '路面危害-松散', '5', 'xxxxxxx'],
          ['2019-07-02 17:25:00', '路面危害-路面油污清理', '13', 'xxxxxxx'],
          ['2019-07-03 16:25:00', '交安设施-交通标志牌结构', '6', 'xxxxxxx'],
          ['2019-07-04 15:25:00', '路基危害-防尘网', '2', 'xxxxxxx'],
          ['2019-07-05 14:25:00', '交安设施-交通标志牌结构', '1', 'xxxxxxx'],
          ['2019-07-06 13:25:00', '路面危害-松散', '3', 'xxxxxxx'],
          ['2019-07-07 12:25:00', '路基危害-防尘网', '4', 'xxxxxxx'],
          ['2019-07-08 11:25:00', '路面危害-路面油污清理', '2', 'xxxxxxx'],
          ['2019-07-09 10:25:00', '交安设施-交通标志牌结构', '5', 'xxxxxxx'],
          ['2019-07-10 09:25:00', '路基危害-防尘网', '3', 'xxxxxxx']
        ],*/
        index: true,
        //columnWidth: [50, 20, 300],
        align: ['center'],
        rowNum: 7,
        waitTime: 2000,
        //headerBGC: '#1981f6',
        //headerHeight: 30,
        oddRowBGC: 'rgba(0, 44, 81, 0.8)',
        evenRowBGC: 'rgba(10, 29, 50, 0.8)'
      }
    }
  },
  methods:{
    getData(){
      const that=this;
      that.config = that.config0;
      this.api.getDeviceAlarmActualForChart().then(res=>{
        apiResult(res.data,false,result=>{
          let configData = [];
          let itemData=[];
          //console.log(">>>>>>AlarmActualList.getData: data=%o",res.data.data);
          //console.log(">>>>>>AlarmActualList.getData: config.data=%o",that.config.data);
          if (!!result.data && result.data.length > 0){
            for(let i in res.data.data){
              itemData=[]
              itemData.push(result.data[i].alarmTime)
              itemData.push(result.data[i].shortName)
              itemData.push(result.data[i].alarmDescription)
              configData.push(itemData);
            }

            that.config1.data=configData;
            that.config=that.config1;
            //console.log(">>>>>>AlarmActualList.getData: config.data=%o",that.config.data);
          }
        })

      })
    }
  },
  mounted() {

    let that = this;
    that.getData();
    this.timer = setInterval(() => {
      that.getData();
    },180000);
  },
  beforeDestroy() {
    if (!!this.timer){
      clearInterval(this.timer)
      this.timer=null;
    }


  }
}
</script>

<style lang="less">
#scroll-board1 {
  width: 100%;
  height: 87%;
  box-sizing: border-box;
  margin-left: 20px;
  margin-top: 10px;
  overflow: hidden;
  font-size: 10px;
}

.dv-scroll-board .rows .row-item {
  font-size: 10px !important;
}

</style>
